<template>
  <view class="featured-card">
    <view class="image-container">
      <view class="overlay"></view>
      <image :src="image" mode="aspectCover" class="cover-image" />
      <view class="image-content">
        <view>
          <view v-for="(tag, index) in tags" :key="index" class="tag">
            {{ tag }}
          </view>
          <text class="title">{{ title }}</text>
        </view>
        <view class="play-button">
          <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="white"
            stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
            <polygon points="5 3 19 12 5 21 5 3"></polygon>
          </svg>
        </view>
      </view>
    </view>

    <view class="card-content">
      <view class="progress-section">
        <view class="subtitle-container">
          <view class="subtitle-badge">
            {{ subtitle }}
          </view>
        </view>
        <text class="progress-text">{{ progress }}%</text>
      </view>

      <view class="progress-bar">
        <view class="progress-indicator" :style="{ width: `${progress}%` }"></view>
      </view>

      <view class="footer">
        <view class="instructor">
          <view class="instructor-avatar">
            <image src="/static/images/avatar.png" mode="aspectFill" />
            <view v-if="isOnline" class="online-indicator">在线</view>
          </view>
          <text class="instructor-name">{{ instructor }}</text>
        </view>
        <view class="continue-button">
          <text>继续学习</text>
          <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none"
            stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
            <path d="m9 18 6-6-6-6"></path>
          </svg>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
defineProps({
  title: {
    type: String,
    required: true
  },
  subtitle: {
    type: String,
    required: true
  },
  progress: {
    type: Number,
    default: 0
  },
  image: {
    type: String,
    default: '/static/images/placeholder.png'
  },
  tags: {
    type: Array,
    default: () => []
  },
  instructor: {
    type: String,
    default: ''
  },
  isOnline: {
    type: Boolean,
    default: false
  }
});
</script>

<style scoped>
.featured-card {
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(to bottom right, #3b82f6, #2563eb);
  box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.2);
}

.image-container {
  position: relative;
  height: 192px;
}

.overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(37, 99, 235, 0.9), transparent);
  z-index: 1;
}

.cover-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  z-index: 2;
}

.tag {
  display: inline-block;
  background-color: rgba(37, 99, 235, 0.5);
  backdrop-filter: blur(4px);
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  color: white;
  margin-bottom: 4px;
}

.title {
  font-size: 20px;
  font-weight: 700;
  color: white;
}

.play-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(4px);
  color: white;
  transition: transform 0.2s;
}

.play-button:active {
  transform: scale(1.05);
}

.card-content {
  padding: 16px;
}

.progress-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.subtitle-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.subtitle-badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 9999px;
  background-color: rgba(37, 99, 235, 0.3);
  font-size: 12px;
  font-weight: 500;
  color: white;
}

.progress-text {
  font-size: 14px;
  font-weight: 500;
  color: rgba(219, 234, 254, 1);
}

.progress-bar {
  height: 6px;
  border-radius: 3px;
  background-color: rgba(37, 99, 235, 0.3);
  overflow: hidden;
}

.progress-indicator {
  height: 100%;
  background-color: white;
  border-radius: 3px;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}

.instructor {
  display: flex;
  align-items: center;
  gap: 8px;
}

.instructor-avatar {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid white;
  overflow: hidden;
}

.instructor-avatar image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.online-indicator {
  position: absolute;
  bottom: -4px;
  right: -4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: #10b981;
  font-size: 8px;
  color: white;
}

.instructor-name {
  font-size: 12px;
  color: rgba(219, 234, 254, 1);
}

.continue-button {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 6px;
  background-color: rgba(255, 255, 255, 0.2);
  font-size: 12px;
  color: white;
}

.continue-button:active {
  background-color: rgba(255, 255, 255, 0.3);
}
</style>